<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<?php
if(!isset($_SESSION)){
	session_start();
}


if(!isset($_SESSION["adminName"]) || (empty($_SESSION["adminName"]))){
	header ("Location: ../index.php");
}
include 'class_pager.php';
?>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Content Page</title>
    <link href="../../Styles/adminstype.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table>
	<tr class="boxContentTitle">
		<td>Danh sách nhà sản xuất</td>
	</tr>
	<tr class="boxContentCommand">
		<td><a href="<?php
			$add = "add";
			echo("admin_manager_manufacture.php?act=$add");
		?>">Thêm mới</a></td>
	</tr>
	<tr>
		<td>
			<?php
			//--------Phan trang -----------------
			
			$p = new Pager();
			$limit = 4;
			$start = $p->findStart($limit);
			$sqlInit = "select * from hangsanxuat";
			
			require_once "../database/DataProvider.php";
			$resultInit =  DataProvider::ExecuteQuery($sqlInit);
			$count = mysql_num_rows($resultInit);
			$pages = $p->findPages($count, $limit);
			
			//------------end phan trang-----------
			$sql = "select * from hangsanxuat LIMIT " . $start . ", " . $limit;
			
			$result =  DataProvider::ExecuteQuery($sql);
			if(!empty($result))
			{
				$edit = "edit";
				$delete = "delete";
				$i = 0;
				echo("<table cellspacing='1' cellpadding='5' class='tableBoxView'>
						<tr class='tableBoxView_title'>
							<td> STT </td>
							<td> Tên nhà sản xuất </td>
							<td> Bị xóa </td>
							<td> Sửa </td>
							<td> Xóa </td>
						");
				while ($row=mysql_fetch_array($result)){
					$i++;
					$id = $row["MaHangSanXuat"];
					$TenHangSanXuat = $row["TenHangSanXuat"];
					$BiXoa = ($row["BiXoa"] == 0 ? 'Đang hoạt động' : 'Bị Xóa');
					
					if($i % 2 != 0){
						echo("<tr class='tableBoxView_row2'>");
					} else {
						echo("<tr class='tableBoxView_row1'>");
					}
					echo("<td>" . $i . "</td>");
					echo("<td>" . $TenHangSanXuat . "</td>");
					echo("<td>" . $BiXoa . "</td>");
					echo("<td><a href='admin_manager_manufacture.php?act=$edit&&id=$id'>Sửa</a></td>");
					echo("<td><a href='admin_manager_manufacture.php?act=$delete&&id=$id'>Xóa</a></td></tr>");
				}	
				echo("</table>");
			}
			?>
		</td>
	</tr>
	<tr class="pager">
		<td>
		<?php 
			$pagelist = $p->pageList($_GET["page"], $pages);
			echo("<p align = 'center' >");
			echo ($pagelist);
			echo("</p>");
			
		?>
		
		</td>
	</tr>
</table>
</body>
</html>